//
//  CJRECMainCollectionViewCell.m
//  CoJellyCartoon
//
//  Created by dllo on 16/3/31.
//  Copyright © 2016年 CJG. All rights reserved.
//

#import "CJRECMainCollectionViewCell.h"

@implementation CJRECMainCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.RECCartoonPic = [[UIImageView alloc] initWithFrame:CGRectZero];
        [self.contentView addSubview:self.RECCartoonPic];
//        self.backgroundColor = [UIColor yellowColor];
        self.RECTitle = [[CJBaseLabel alloc] initWithFrame:CGRectZero];
        self.RECTitle.font = [UIFont systemFontOfSize:14.0];
        self.RECTitle.numberOfLines = 2;
        [self.contentView addSubview:self.RECTitle];
        
        self.recplaycountpic = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.recplaycountpic.image = [[UIImage imageNamed:@"recplaycountpic"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        [self.contentView addSubview:self.recplaycountpic];
        
        self.RECPlayCounts = [[CJBaseLabel alloc] initWithFrame:CGRectZero];
        self.RECPlayCounts.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.RECPlayCounts];
        
        self.reccommentspic = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.reccommentspic.image = [[UIImage imageNamed:@"pinglun"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        [self.contentView addSubview:self.reccommentspic];
        
        self.RECComments = [[CJBaseLabel alloc] initWithFrame:CGRectZero];
        self.RECComments.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.RECComments];
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    self.RECCartoonPic.frame = CGRectMake(0, 0, self.contentView.bounds.size.width, self.contentView.bounds.size.height/1.7);
    self.RECTitle.frame = CGRectMake(0, self.RECCartoonPic.frame.size.height, self.contentView.bounds.size.width, self.contentView.bounds.size.height / 4);
    
    self.recplaycountpic.frame = CGRectMake(0, self.RECTitle.frame.origin.y + self.RECTitle.frame.size.height  + 3, 20, 20);
    //评论次数
    self.RECPlayCounts.frame = CGRectMake(self.recplaycountpic.frame.origin.x + self.recplaycountpic.frame.size.width + 3, self.RECTitle.frame.origin.y + self.RECTitle.frame.size.height + 3, 100, 20);
    
    self.reccommentspic.frame = CGRectMake(self.contentView.frame.size.width -60, self.RECTitle.frame.origin.y + self.RECTitle.frame.size.height + 3, 20, 20);
    //播放次数
    self.RECComments.frame = CGRectMake(self.reccommentspic.frame.origin.x +self.reccommentspic.frame.size.width + 3 , self.RECTitle.frame.origin.y + self.RECTitle.frame.size.height + 3, 40, 20);
    
}
-(void)setRecBodyModel:(CJRECInBodyModel *)RecBodyModel{
    _RecBodyModel = RecBodyModel;
    [self.RECCartoonPic sd_setImageWithURL:[NSURL URLWithString:RecBodyModel.cover] placeholderImage:[UIImage imageNamed:@"zhanweiye"]];
    self.RECTitle.text = RecBodyModel.title;
    
    if (RecBodyModel.play) {
        
       self.RECPlayCounts.text = RecBodyModel.play;
    }
    
    if (RecBodyModel.desc1) {
//        [self.recplaycountpic removeFromSuperview];
//        [self.reccommentspic removeFromSuperview];
        self.RECPlayCounts.text = RecBodyModel.desc1;
    
    }

    if (RecBodyModel.danmaku) {
    self.RECComments.text = RecBodyModel.danmaku;
    }
    
    
}
@end
